var win = 0;
var lose = 0;
var draw = 0;

// 选择出拳
function select() {
    var select = document.getElementById("select").value;
    var current = document.getElementById("current");
    if (select == 1) {
        current.src = "img/st.jpg";
    } else if (select == 2) {
        current.src = "img/jd.jpg";
    } else if (select == 3) {
        current.src = "img/bu.jpg";
    } else {
        current.src = "img/zb.jpg";
    }
}

// 确认出拳
function confirm() {
    var select = document.getElementById("select").value;
    var you = document.getElementById("you");
    var computer = document.getElementById("computer");

    // 你出拳
    if (select == 1) {
        you.src = "img/st.jpg";
    } else if (select == 2) {
        you.src = "img/jd.jpg";
    } else if (select == 3) {
        you.src = "img/bu.jpg";
    } else {
        alert("请先选择，再出拳！");
        return false;
    }

    // 电脑出拳
    var x = parseInt(Math.random()*3+1);
    if (x == 1) {
        computer.src = "img/st.jpg";
    } else if (x == 2) {
        computer.src = "img/jd.jpg";
    } else if (x == 3) {
        computer.src = "img/bu.jpg";
    }

    // 判断猜拳
    var result = document.getElementById("result")
    var minus = select - x;
    if (minus == 0) {
        result.innerText = "平局";
        draw++;
    } else if (minus == 2 || minus == -1) {
        result.innerText = "胜利";
        win++;
    } else {
        result.innerText = "失败";
        lose++;
    }

    // 显示结果
    document.getElementById("total").innerText = win + lose + draw;
    document.getElementById("win").innerText = win;
    document.getElementById("lose").innerText = lose;
    document.getElementById("draw").innerText = draw;

}